import { PageDateSelect } from '@/types/pages/enum';
import { IPurchase } from '@/types/pages/purchase/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';

/** 采购预览1 */
export const getPurchaseMoneyData : (type: PageDateSelect, date?: Date) => Promise<IPurchase> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => { 
        let data: IPurchase = {  name: '总金额', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        res(Mock.mock(data));
    })

}
/** 采购预览2 */
export const getPurchaseNumData: (type: PageDateSelect, date?: Date) => Promise<IPurchase> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data: IPurchase = {  name: '总量', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '吨', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        res(Mock.mock(data));
    })

}
/** 原料采购占比（吨） */
export const getMaterialPieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '原料采购占比（吨）', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '榆林化学' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })

}
/** 原料采购占比（万元） */
export const getPurchasePieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '原料采购占比（万元）', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })
} 

/** 原料煤采购情况 */
export const getMaterialColumnChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDateLineChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a=()=>(Math.random()*100).toFixed(2)
        const dataset:IDateLineChart={title:'原料煤采购情况',dataset:{dimensions:['客户','数值'],source:[{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()}]}}
        res(Mock.mock(dataset));
    })
}

/** 单价采购趋势 */
export const getPurchaseLineChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDateLineChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a = () => (Math.random() * 100).toFixed(2)
        const dataset: IDateLineChart = { title: '单价采购趋势', dataset: { dimensions: ['date', '实际', '预测'], source: [{ 'date': '2021-01-7', '实际': a(), '预测': a() }, { 'date': '2021-01-8', '实际': a(), '预测': a() }] } }
        res(Mock.mock(dataset));
    })
}


 




